/*
** my_putnbr.c for my_put_nbr in /home/leroy_v//Jour_03/exo07
** 
** Made by vincent leroy
** Login   <leroy_v@epitech.net>
** 
** Started on  Wed Oct  3 16:47:55 2012 vincent leroy
** Last update Tue Feb 05 16:55:38 2013 vincent leroy
*/

#include <unistd.h>

long	my_putchar(char c)
{
    return write(1, &c, 1);
}

long	my_loop_prlong(long *n, long *pow)
{
    long	res;

    res = 0;
    while (*pow >= 1)
    {
        res++;
        my_putchar(*n / *pow + '0');
        *n %= *pow;
        *pow /= 10;
    }
    return (res);
}

long	my_putnbr(long n)
{
    long	pow;
    long	res;

    res = 0;
    if (n < 0)
    {
        res++;
        my_putchar('-');
        n = -n;
    }
    pow = 1;
    while (pow <= n / 10)
        pow *= 10;
    res += my_loop_prlong(&n, &pow);
    return (res);
}
